package com.bruce.apkinstaller.other;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

public class UIUtils {
	private static Toast toast;
	
	/**
	 * 跳转设置
	 * 
	 * @param context
	 * @return
	 */
	public static void goToSetting(Context context) {
		try {
			// 海信调用设置界面
			if (Util.checkPackage(context, "com.android.tv.settings")) {
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.android.tv.settings");// hisense
				context.startActivity(intent);
			}else if (Util.checkPackage(context, "com.haier.tv.networksettings")) {
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.haier.tv.networksettings");// haier 网络设置
				context.startActivity(intent);
			} 
			
			
			else if(Util.checkPackage(context, "com.android.MySettings")){
				//H1 系统设置
				Log.d("","com.android.MySettings");
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.android.MySettings");
				context.startActivity(intent);
			} else if(Util.checkPackage(context, "com.vsoontech.mos.setting")){
				
				Log.d("","com.vsoontech.mos.setting");
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.vsoontech.mos.setting");
				context.startActivity(intent);
				
				
			}else if(Util.checkPackage(context, "com.mbx.settingsmbox")){
				
				Log.d("","com.mbx.settingsmbox");
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.mbx.settingsmbox");
				context.startActivity(intent);
				
				
			}else if (Util.checkPackage(context, "com.baofengtv.settings")) {

				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.baofengtv.settings");
				context.startActivity(intent);

			}else if (Util.checkPackage(context, "com.android.settings")) {
				Intent intent = new Intent();
				intent = context.getPackageManager().getLaunchIntentForPackage(
						"com.android.settings");
				context.startActivity(intent);
			} 

		} catch (Exception e) {
		}
	}
	
	/**
	 * showToast
	 * @param context
	 * @param msg
	 */
	public static void showToast(Context context, String msg){
		if(toast == null){
			toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
		} else{
			toast.setText(msg);
		}
		
		toast.show();
	}
	
	private static ProgressDialog loadingDialog;
	
	public static void showLoadingDialog(Context context, String msg){
		if(loadingDialog == null){
			loadingDialog = new ProgressDialog(context);
			loadingDialog.setMessage(msg);
			loadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
			loadingDialog.setCancelable(false);
		} else{
			loadingDialog.setMessage(msg);
		}
		
		loadingDialog.show();
	}
	
	public static void dismissLoadingDialog(){
		if(null != loadingDialog && loadingDialog.isShowing()){
			loadingDialog.dismiss();
		}
	}
}
